/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package comboboxview;

import data.Departments;

import java.util.ArrayList;
import java.util.List;
import javax.swing.AbstractListModel;
import javax.swing.ComboBoxModel;

/**
 *
 * @author Hùng
 */
public class DepartmentCbView extends AbstractListModel implements ComboBoxModel {
    List<Departments> ldept ;
    Object selecttion = null;
    public DepartmentCbView() {
       new ArrayList<Departments>();
    }

    public DepartmentCbView(List<Departments> ldept) {
        this.ldept = ldept;
    }
    
    public List<Departments> getLdept() {
        return ldept;
    }

   
    @Override
    public int getSize() {
        return  ldept.size();
      
    }

    @Override
    public Object getElementAt(int index) {
        return ldept.get(index).getDeptname();
    }

    @Override
    public void setSelectedItem(Object anItem) {
        selecttion = anItem;
    }

    @Override
    public Object getSelectedItem() {
        return selecttion;
       
    }
    
}
